
<style scoped lang="scss">
@import url('index.scss');
</style>

<template>
  <div class="app-container">
    <!--新模版样式-->
    <div class="topsearch">
      <el-row>
        <el-col :span="24" class="searchcol">
          <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
            <el-form-item label="采购明细ID" prop="itemId">
              <el-input v-model="queryParams.itemId" placeholder="请输入采购明细ID" clearable @keyup.enter="handleQuery" />
            </el-form-item>
            <el-form-item label="实际到货时间" prop="arriveTime">
              <el-date-picker clearable v-model="queryParams.arriveTime" type="date" value-format="YYYY-MM-DD"
                placeholder="请选择实际到货时间">
              </el-date-picker>
            </el-form-item>
            <!-- <el-form-item label="实测活度" prop="arriveActivitymbq">
              <el-input v-model="queryParams.arriveActivitymbq" placeholder="请输入实测活度" clearable
                @keyup.enter="handleQuery" />
            </el-form-item> -->
            <!-- <el-form-item label="表面剂量率(μSv/h)" prop="surfaceUsv">
              <el-input v-model="queryParams.surfaceUsv" placeholder="请输入表面剂量率(μSv/h)" clearable
                @keyup.enter="handleQuery" />
            </el-form-item> -->
            <!-- <el-form-item label="监测方位" prop="surfacePoint">
              <el-input v-model="queryParams.surfacePoint" placeholder="请输入监测方位" clearable @keyup.enter="handleQuery" />
            </el-form-item>
            <el-form-item label="表面污染擦拭活度(Bq)" prop="contaminationWipebq">
              <el-input v-model="queryParams.contaminationWipebq" placeholder="请输入表面污染擦拭活度(Bq)" clearable
                @keyup.enter="handleQuery" />
            </el-form-item> -->
            <el-form-item label="发票号" prop="invoiceNo">
              <el-input v-model="queryParams.invoiceNo" placeholder="请输入发票号" clearable @keyup.enter="handleQuery" />
            </el-form-item>
            <el-form-item label="批次号" prop="piciNo">
              <el-input v-model="queryParams.piciNo" placeholder="请输入批次号" clearable @keyup.enter="handleQuery" />
            </el-form-item>
            <!-- <el-form-item label="泄露测试报告url" prop="leakTesturl">
              <el-input v-model="queryParams.leakTesturl" placeholder="请输入泄露测试报告url" clearable
                @keyup.enter="handleQuery" />
            </el-form-item> -->
            <el-form-item label="验收人员" prop="acceptUser">
              <el-input v-model="queryParams.acceptUser" placeholder="请输入验收人员" clearable @keyup.enter="handleQuery" />
            </el-form-item>
            <el-form-item label="验收完成时间" prop="acceptTime">
              <el-date-picker clearable v-model="queryParams.acceptTime" type="date" value-format="YYYY-MM-DD"
                placeholder="请选择验收完成时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="验收结论" prop="acceptResult">
              <el-input v-model="queryParams.acceptResult" placeholder="请输入验收结论" clearable @keyup.enter="handleQuery" />
            </el-form-item>
            <!-- <el-form-item label="采购验收签名" prop="acceptSigncg">
              <el-input v-model="queryParams.acceptSigncg" placeholder="请输入采购验收签名" clearable
                @keyup.enter="handleQuery" />
            </el-form-item> -->
            <!-- <el-form-item label="验收员签名" prop="acceptSignhy">
              <el-input v-model="queryParams.acceptSignhy" placeholder="请输入验收员签名" clearable
                @keyup.enter="handleQuery" />
            </el-form-item>
            <el-form-item label="拒收原因" prop="rejectReason">
              <el-input v-model="queryParams.rejectReason" placeholder="请输入拒收原因" clearable @keyup.enter="handleQuery" />
            </el-form-item> -->
            <el-form-item>
              <el-button class="newButton" icon="Search" @click="handleQuery">搜索</el-button>
              <el-button icon="Refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="22" class="rightcol">
          <div class="newbtn" @click="handleAdd" v-hasPermi="['system:accept:add']">
            <img src="@/assets/images/add.svg" alt="">
            <span>新建</span>
          </div>
          <div class="newbtn" v-if="single == false" @click="handleUpdate" v-hasPermi="['system:accept:edit']">
            <img src="@/assets/images/edit.svg" alt=""></img>
            <span>编辑</span>
          </div>
          <div class="newbtn" v-if="multiple == false" @click="handleDelete" v-hasPermi="['system:accept:remove']">
            <img src="@/assets/images/del.svg" alt=""></img>
            <span>删除</span>
          </div>
          <div class="newbtn" @click="handleExport" v-hasPermi="['system:accept:export']">
            <img src="@/assets/images/export.svg" alt=""></img>
            <span>导出</span>
          </div>
          <div class="newbtn" @click="getList">
            <img src="@/assets/images/refresh.svg" alt=""></img>
            <span>刷新</span>
          </div>
        </el-col>
      </el-row>
    </div>

    <!-- <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:accept:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
          v-hasPermi="['system:accept:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['system:accept:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="Download" @click="handleExport"
          v-hasPermi="['system:accept:export']">导出</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row> -->

    <el-table v-loading="loading" :data="acceptList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="验收ID" align="center" prop="acceptid" />
      <el-table-column label="采购明细ID" align="center" prop="itemId" />
      <el-table-column label="实际到货时间" align="center" prop="arriveTime" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.arriveTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实测活度" align="center" prop="arriveActivitymbq" />
      <el-table-column label="表面剂量率(μSv/h)" align="center" prop="surfaceUsv" />
      <el-table-column label="监测方位" align="center" prop="surfacePoint" />
      <el-table-column label="表面污染擦拭活度(Bq)" align="center" prop="contaminationWipebq" />
      <el-table-column label="包装状态" align="center" prop="packageStatus" />
      <el-table-column label="发票号" align="center" prop="invoiceNo" />
      <el-table-column label="批次号" align="center" prop="piciNo" />
      <el-table-column label="泄露测试报告url" align="center" prop="leakTesturl" />
      <el-table-column label="验收人员" align="center" prop="acceptUser" />
      <el-table-column label="验收完成时间" align="center" prop="acceptTime" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.acceptTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="验收结论" align="center" prop="acceptResult" />
      <el-table-column label="采购验收签名" align="center" prop="acceptSigncg" />
      <el-table-column label="验收员签名" align="center" prop="acceptSignhy" />
      <el-table-column label="拒收原因" align="center" prop="rejectReason" />
      <el-table-column label="状态" align="center" prop="status" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['system:accept:edit']">修改</el-button>
          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
            v-hasPermi="['system:accept:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改收货质检对话框 -->
    <el-dialog :title="title" v-model="open" width="50%" class="newDialog">
      <el-form ref="acceptRef" :model="form" :rules="rules" label-width="160px">
        <el-row :gutter="20">
          <el-col :span="12">
        <el-form-item label="采购明细ID" prop="itemId">
          <el-input v-model="form.itemId" placeholder="请输入采购明细ID" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="实际到货时间" prop="arriveTime">
          <el-date-picker clearable v-model="form.arriveTime" type="date" value-format="YYYY-MM-DD"
            placeholder="请选择实际到货时间">
          </el-date-picker>
        </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
       <el-form-item label="实测活度" prop="arriveActivitymbq">
          <el-input v-model="form.arriveActivitymbq" placeholder="请输入实测活度" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="表面剂量率(μSv/h)" prop="surfaceUsv">
          <el-input v-model="form.surfaceUsv" placeholder="请输入表面剂量率(μSv/h)" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
        <el-form-item label="监测方位" prop="surfacePoint">
          <el-input v-model="form.surfacePoint" placeholder="请输入监测方位" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="表面污染擦拭活度(Bq)" prop="contaminationWipebq">
          <el-input v-model="form.contaminationWipebq" placeholder="请输入表面污染擦拭活度(Bq)" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
        <el-form-item label="发票号" prop="invoiceNo">
          <el-input v-model="form.invoiceNo" placeholder="请输入发票号" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="批次号" prop="piciNo">
          <el-input v-model="form.piciNo" placeholder="请输入批次号" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
       <el-form-item label="泄露测试报告url" prop="leakTesturl">
          <el-input v-model="form.leakTesturl" placeholder="请输入泄露测试报告url" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="验收人员" prop="acceptUser">
          <el-input v-model="form.acceptUser" placeholder="请输入验收人员" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
        <el-form-item label="验收完成时间" prop="acceptTime">
          <el-date-picker clearable v-model="form.acceptTime" type="date" value-format="YYYY-MM-DD"
            placeholder="请选择验收完成时间">
          </el-date-picker>
        </el-form-item>
          </el-col>
          <el-col :span="12">
        <el-form-item label="验收结论" prop="acceptResult">
          <el-input v-model="form.acceptResult" placeholder="请输入验收结论" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
        <el-form-item label="采购验收签名" prop="acceptSigncg">
          <el-input v-model="form.acceptSigncg" placeholder="请输入采购验收签名" />
        </el-form-item>
          </el-col>
          <el-col :span="12">
      <el-form-item label="验收员签名" prop="acceptSignhy">
          <el-input v-model="form.acceptSignhy" placeholder="请输入验收员签名" />
        </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="拒收原因" prop="rejectReason">
          <el-input v-model="form.rejectReason" placeholder="请输入拒收原因" type="textarea" :rows="4" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Accept">
import { listAccept, getAccept, delAccept, addAccept, updateAccept } from "@/api/system/accept"

const { proxy } = getCurrentInstance()

const acceptList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    itemId: null,
    arriveTime: null,
    arriveActivitymbq: null,
    surfaceUsv: null,
    surfacePoint: null,
    contaminationWipebq: null,
    packageStatus: null,
    invoiceNo: null,
    piciNo: null,
    leakTesturl: null,
    acceptUser: null,
    acceptTime: null,
    acceptResult: null,
    acceptSigncg: null,
    acceptSignhy: null,
    rejectReason: null,
    status: null,
  },
  rules: {
  }
})

const { queryParams, form, rules } = toRefs(data)

/** 查询收货质检列表 */
function getList() {
  loading.value = true
  listAccept(queryParams.value).then(response => {
    acceptList.value = response.rows
    total.value = response.total
    loading.value = false
  })
}

// 取消按钮
function cancel() {
  open.value = false
  reset()
}

// 表单重置
function reset() {
  form.value = {
    acceptid: null,
    itemId: null,
    arriveTime: null,
    arriveActivitymbq: null,
    surfaceUsv: null,
    surfacePoint: null,
    contaminationWipebq: null,
    packageStatus: null,
    invoiceNo: null,
    piciNo: null,
    leakTesturl: null,
    acceptUser: null,
    acceptTime: null,
    acceptResult: null,
    acceptSigncg: null,
    acceptSignhy: null,
    rejectReason: null,
    status: null,
    createBy: null,
    createTime: null,
    updateBy: null,
    updateTime: null
  }
  proxy.resetForm("acceptRef")
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1
  getList()
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef")
  handleQuery()
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.acceptid)
  single.value = selection.length != 1
  multiple.value = !selection.length
}

/** 新增按钮操作 */
function handleAdd() {
  reset()
  open.value = true
  title.value = "添加收货质检"
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset()
  const _acceptid = row.acceptid || ids.value
  getAccept(_acceptid).then(response => {
    form.value = response.data
    open.value = true
    title.value = "修改收货质检"
  })
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["acceptRef"].validate(valid => {
    if (valid) {
      if (form.value.acceptid != null) {
        updateAccept(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功")
          open.value = false
          getList()
        })
      } else {
        addAccept(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功")
          open.value = false
          getList()
        })
      }
    }
  })
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _acceptids = row.acceptid || ids.value
  proxy.$modal.confirm('是否确认删除收货质检编号为"' + _acceptids + '"的数据项？').then(function() {
    return delAccept(_acceptids)
  }).then(() => {
    getList()
    proxy.$modal.msgSuccess("删除成功")
  }).catch(() => {})
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download('system/accept/export', {
    ...queryParams.value
  }, `accept_${new Date().getTime()}.xlsx`)
}

getList()
</script>
